<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册 - 后台管理系统</title>
    <!-- 引入layui -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/layui/2.9.7/css/layui.min.css">
    <script src="https://cdn.staticfile.org/layui/2.9.7/layui.min.js"></script>
    <style>
        body {
            background-color: #f2f2f2;
        }
        .register-container {
            width: 400px;
            margin: 80px auto;
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        .register-title {
            text-align: center;
            margin-bottom: 20px;
            font-size: 20px;
            font-weight: bold;
            color: #333;
        }
    </style>
</head>
<body>
    <div class="register-container">
        <div class="register-title">后台管理系统 - 注册</div>
        <form class="layui-form" action="{{ url_for('auth.register') }}" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input type="text" name="username" required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" required  lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">确认密码</label>
                <div class="layui-input-block">
                    <input type="password" name="confirm_password" required  lay-verify="required" placeholder="请再次输入密码" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="register">注册</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
            <div class="layui-form-item" style="text-align: center;">
                <a href="{{ url_for('auth.login') }}">已有账号？立即登录</a>
            </div>
        </form>
    </div>

    <script>
        // 初始化layui
        layui.use(['form', 'layer'], function() {
            var form = layui.form;
            var layer = layui.layer;

            // 监听表单提交
            form.on('submit(register)', function(data) {
                // 表单验证通过，可以在这里添加额外的逻辑
                return true;
            });

            // 显示flash消息
            {% with messages = get_flashed_messages(with_categories=true) %}
                {% if messages %}
                    {% for category, message in messages %}
                        {% if category == 'success' %}
                            layer.msg('{{ message }}', {icon: 1});
                        {% else %}
                            layer.msg('{{ message }}', {icon: 2});
                        {% endif %}
                    {% endfor %}
                {% endif %}
            {% endwith %}
        });
    </script>
</body>
</html>